import uni from '@dcloudio/vite-plugin-uni'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import JSX from '@vitejs/plugin-vue-jsx'
import { defineConfig } from 'vite'
import { VantResolver } from 'unplugin-vue-components/resolvers'

// https://vitejs.dev/config/
export default defineConfig({
  base: '/my-components/',
  server: {
    host: '0.0.0.0',
    port: 4598
  },
  plugins: [
    uni(),
    AutoImport({
      include: [/.[tj]sx?$/, /.vue$/, /.vue?vue/],
      imports: ['vue', 'uni-app', '@vueuse/core'],
      dirs: ['./src/hook'],
      dts: './src/typings/auto-imports.d.ts',
      vueTemplate: true
    }),
    Components({
      resolvers: [VantResolver()],
      dts: './src/typings/components.d.ts'
    }),
    JSX()
  ],
  css: {
    preprocessorOptions: {
      scss: {
        additionalData: '@import "@/style/uni.scss";'
      }
    }
  }
})
